﻿using AiBLSmartEdu.Module.AISlimmingAssistant.API.DTOs;
using AiBLSmartEdu.Module.AISlimmingAssistant.API.Services;
using FrameworkCore;
using FrameworkCore.Controllers;
using FrameworkCore.Models;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AiBLSmartEdu.Module.AISlimmingAssistant.API.Controllers
{
    /// <summary>
    /// AI减肥管理
    /// </summary>
    public class AISlimmingAssistantController : BaseModuleController
    {
        private readonly SlimmingAssistantServices _services;

        public AISlimmingAssistantController(SlimmingAssistantServices services)
        {
            _services = services;
        }


        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="filter">分页输入模型</param>
        /// <returns></returns>
        [HttpGet("Page")]
        public async Task<PageResult<SlimmingAssistantOutputModel>> PaginationAsync([FromQuery] SlimmingAssistantPaginationFilter filter)
        {
            return await _services.PageAsync(filter);
        }

        /// <summary>
        /// 填写个人信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result<long>> CreateAsync(SlimmingAssistantCreateInputModel input) 
        {
            return await Result<long>.SucceedAsync(await _services.CreateAsync(input));
        }

        /// <summary>
        /// 获取推荐
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost("{id}")]
        public async Task<Result<SlimmingAssistantOutputModel>> GetReferralsAsync(long id) 
        {
            return await Result<SlimmingAssistantOutputModel>.SucceedAsync(await _services.GetReferralsAsync(id));
        }

        /// <summary>
        /// 删除信息
        /// </summary>
        /// <param name="id">唯一标识</param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<Result> DeleteAsync(long id)
        {
            await _services.DeleteAsync(id);
            return await Result.SucceedAsync();
        }
    }
}
